credit2: Avoid extra c2t calcuation in csched_runtime
authorGeorge Dunlap <george.dunlap@eu.citrix.com>
Mon, 4 Mar 2013 12:38:45 +0000 (13:38 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 4 Mar 2013 12:38:45 +0000 (13:38 +0100)
commit8b3072a050a67405022f9e7911c37ccff9c0cdb5
treef9b72894159914547c68e3241d954755e2e47098
parentbe6507509454adf3bb5a50b9406c88504e996d5a
credit2: Avoid extra c2t calcuation in csched_runtime

csched_runtime() needs to call the ct2() function to change credits
into time.  The c2t() function, however, is expensive, as it requires
an integer division.

c2t() was being called twice, once for the main vcpu's credit and once
for the difference between its credit and the next in the queue.  But
this is unnecessary; by calculating in "credit" first, we can make it
so that we just do one conversion later in the algorithm.

This also adds more documentation describing the intended algorithm,
along with a relevant assertion..

The effect of the new code should be the same as the old code.

Spotted-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
xen/common/sched_credit2.c